package com.example.testanimation.fragment.switchanimation;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;

import com.nova.scenic.projectlibs.util.fragment.BaseFragment;
import com.scenic.rd_android.R;

/**
 * Created by scenic on 3/26/15.
 */
public class InformationFragment extends BaseFragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_switch_animtion_information,null);
    }

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        Bundle bundle = getArguments() ;
        final int x = bundle.getInt("x");
        final int y = bundle.getInt("y");
        final int width = bundle.getInt("width");
        final int height = bundle.getInt("height");
        getView().getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
            @Override
            public boolean onPreDraw() {
                new ScaleViewAnimation(getView(),x,y,width,height).start(new AnimatorListenerAdapter() {
                    @Override
                    public void onAnimationEnd(Animator animation) {
//                        getFragmentManager().findFragmentByTag("")
                    }
                });
                getView().getViewTreeObserver().removeOnPreDrawListener(this);
                return false;
            }
        });

    }
}
